//package cn.com.open.errorquestion.common;
//
//import cn.com.open.errorquestion.model.AnswerQuestionLog;
//import cn.com.open.errorquestion.service.AnswerQuestionLogService;
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.TypeReference;
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.Optional;
//
//@Component
//public class KafkaReceiver {
//
//    @Autowired
//    private AnswerQuestionLogService answerQuestionLogService;
//
//
//    @KafkaListener(topics = {"error-question"})
//    public void listen(ConsumerRecord<?, ?> record) {
//        Optional<?> value = Optional.ofNullable(record.value());
//        if(value.isPresent()){
//            ArrayList<AnswerQuestionLog> answerDatas = JSON.parseObject((String) value.get(), new TypeReference<ArrayList<AnswerQuestionLog>>() {});
//            answerQuestionLogService.saveQuestion(answerDatas);
//        }
//    }
//}
